class Answer implements java.lang.Comparable{
	Question question
	String userId // xxx@example.com
	String department
	String userIp
	Calendar answerTime
	AnswerText at
	SortedSet answerItems

	static mapping = {
		table 'VOTING_ANSWER'
	}

	static belongsTo = Question
	static hasMany = [answerItems: AnswerItem]

    static constraints = {
		userId(blank:false, maxSize: 255)
		department(blank:false, maxSize: 32)
		userIp(blank:false, maxSize: 15)
		answerTime(blank:false)
		at(nullable:true)
    }

	static optionals = {
		["at"]
	}

	String toString() {
		"${this.userId} - ${answerItems}${at?.content}"
	}

	int compareTo(Object a){
		this.userId.compareTo(a.userId)
	}

}
